package com.ezbuy.common.request;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class ObservableTransformerHelper {

    public static <Response> ObservableTransformer<Response, Response> get() {
        return new ObservableTransformer<Response, Response>() {
            @Override
            public ObservableSource<Response> apply(Observable<Response> upstream) {
                //是Android环境就切换回到主线程
                return upstream.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
            }
        };
    }
}
